﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;

namespace Teigha.Core
{
	public class OdGsLayerNode : OdGsNode
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdGsLayerNode(IntPtr cPtr, bool cMemoryOwn) : base(GlobalsPINVOKE.OdGsLayerNode_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdGsLayerNode obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdGsLayerNode()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							GlobalsPINVOKE.delete_OdGsLayerNode(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdGsLayerNode cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGsLayerNode_cast(OdRxObject.getCPtr(pObj));
			OdGsLayerNode result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGsLayerNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGsLayerNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGsLayerNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsLayerNode_desc(), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsLayerNode_isA(this.swigCPtr), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(GlobalsPINVOKE.OdGsLayerNode_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdGsLayerNode createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = GlobalsPINVOKE.OdGsLayerNode_createObject();
			OdGsLayerNode result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdGsLayerNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdGsLayerNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdGsLayerNode)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public OdGsLayerNode(OdGsBaseModel pModel, OdGiDrawable pUnderlyingDrawable, bool bSetGsNode) : this(GlobalsPINVOKE.new_OdGsLayerNode__SWIG_0(OdGsBaseModel.getCPtr(pModel), OdGiDrawable.getCPtr(pUnderlyingDrawable), bSetGsNode), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGsLayerNode(OdGsBaseModel pModel, OdGiDrawable pUnderlyingDrawable) : this(GlobalsPINVOKE.new_OdGsLayerNode__SWIG_1(OdGsBaseModel.getCPtr(pModel), OdGiDrawable.getCPtr(pUnderlyingDrawable)), true)
		{
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public new virtual void destroy()
		{
			GlobalsPINVOKE.OdGsLayerNode_destroy(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public OdGiLayerTraitsData layerTraits(uint nVpId)
		{
			OdGiLayerTraitsData result = new OdGiLayerTraitsData(GlobalsPINVOKE.OdGsLayerNode_layerTraits__SWIG_0(this.swigCPtr, nVpId), false);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void reserveLayerTraits(uint nVpId)
		{
			GlobalsPINVOKE.OdGsLayerNode_reserveLayerTraits(this.swigCPtr, nVpId);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool isDirty()
		{
			bool result = GlobalsPINVOKE.OdGsLayerNode_isDirty(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setDirty(bool bDirty)
		{
			GlobalsPINVOKE.OdGsLayerNode_setDirty(this.swigCPtr, bDirty);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool isUpToDate(uint nVpId)
		{
			bool result = GlobalsPINVOKE.OdGsLayerNode_isUpToDate(this.swigCPtr, nVpId);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isValidCache(uint nVpId)
		{
			bool result = GlobalsPINVOKE.OdGsLayerNode_isValidCache(this.swigCPtr, nVpId);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public void setCacheUpToDate(uint nVpId)
		{
			GlobalsPINVOKE.OdGsLayerNode_setCacheUpToDate(this.swigCPtr, nVpId);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool isInvalidated()
		{
			bool result = GlobalsPINVOKE.OdGsLayerNode_isInvalidated(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isVpDep()
		{
			bool result = GlobalsPINVOKE.OdGsLayerNode_isVpDep(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual ENodeType nodeType()
		{
			ENodeType result = (ENodeType)GlobalsPINVOKE.OdGsLayerNode_nodeType(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public bool isVpFrozen()
		{
			bool result = GlobalsPINVOKE.OdGsLayerNode_isVpFrozen(this.swigCPtr);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual void invalidate(OdGsContainerNode pParent, OdGsViewImpl pView, uint mask)
		{
			GlobalsPINVOKE.OdGsLayerNode_invalidate(this.swigCPtr, OdGsContainerNode.getCPtr(pParent), OdGsViewImpl.getCPtr(pView), mask);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
		}

		public bool isTraitsCompatible(uint nVpId1, uint nVpId2)
		{
			bool result = GlobalsPINVOKE.OdGsLayerNode_isTraitsCompatible(this.swigCPtr, nVpId1, nVpId2);
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual bool saveNodeState(SWIGTYPE_p_OdGsFiler pFiler, OdGsBaseVectorizer pVectorizer)
		{
			bool result = GlobalsPINVOKE.OdGsLayerNode_saveNodeState__SWIG_0(this.swigCPtr, SWIGTYPE_p_OdGsFiler.getCPtr(pFiler), OdGsBaseVectorizer.getCPtr(pVectorizer));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual bool saveNodeState(SWIGTYPE_p_OdGsFiler pFiler)
		{
			bool result = GlobalsPINVOKE.OdGsLayerNode_saveNodeState__SWIG_1(this.swigCPtr, SWIGTYPE_p_OdGsFiler.getCPtr(pFiler));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual bool loadNodeState(SWIGTYPE_p_OdGsFiler pFiler, OdGsBaseVectorizer pVectorizer)
		{
			bool result = GlobalsPINVOKE.OdGsLayerNode_loadNodeState__SWIG_0(this.swigCPtr, SWIGTYPE_p_OdGsFiler.getCPtr(pFiler), OdGsBaseVectorizer.getCPtr(pVectorizer));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual bool loadNodeState(SWIGTYPE_p_OdGsFiler pFiler)
		{
			bool result = GlobalsPINVOKE.OdGsLayerNode_loadNodeState__SWIG_1(this.swigCPtr, SWIGTYPE_p_OdGsFiler.getCPtr(pFiler));
			if (GlobalsPINVOKE.SWIGPendingException.Pending)
			{
				throw GlobalsPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
